package com.fdb.efp.nls.service.impl;

import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.GzBankRepayPlanFileTempDao;
import com.fdb.efp.nls.service.domain.GzBankRepayPlanFileTemp;
import com.fdb.efp.nls.service.facade.GzBankRepayPlanFileTempService;
import com.fdb.efp.nls.service.vo.GzBankRepayPlanFileTempVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("gzBankRepayPlanFileTempService")
/**
 * 贷款还款计划临时表
 * @description:TODO
 * @date:2018年12月26日 下午2:50:35
 * @author:cenyj
 */
public class GzBankRepayPlanFileTempServiceImpl implements GzBankRepayPlanFileTempService, FrameworkService {
private static Logger logger = LoggerFactory.getLogger(GzBankRepayPlanFileTempServiceImpl.class);
	
	@Autowired
	private GzBankRepayPlanFileTempDao gzBankRepayPlanFileTempDao;
	
	/**
	 * 新增操作 先查根据借据编号去查询loan_repay_plan表是否有还款计划信息，没有则新增，有则修改
	 */
	public int insertGzBankRepayPlanFileTemp(GzBankRepayPlanFileTemp gzBankRepayPlanFileTemp) {//vo
		GzBankRepayPlanFileTemp gzBankRepayPlanFileTempVO=new GzBankRepayPlanFileTemp();
		logger.debug("当前新增数据为:"+ gzBankRepayPlanFileTempVO.toString());
		int num = 0;
		try {			
			beanCopy(gzBankRepayPlanFileTempVO, gzBankRepayPlanFileTemp);
			num = gzBankRepayPlanFileTempDao.insert(gzBankRepayPlanFileTemp);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	/**
	 * 删除操作
	 */
	public int deleteAll(GzBankRepayPlanFileTemp gzBankRepayPlanFileTemp) {//vo
		GzBankRepayPlanFileTemp gzBankRepayPlanFileTempVO=new GzBankRepayPlanFileTemp();
		logger.debug("当前删除数据条件为:"+ gzBankRepayPlanFileTempVO);
		int num = 0;
		try {			
			beanCopy(gzBankRepayPlanFileTempVO, gzBankRepayPlanFileTemp);
			num =0;// gzBankRepayPlanFileTempDao.deleteAll(gzBankRepayPlanFileTemp);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
		}
		logger.debug("根据条件:"+ gzBankRepayPlanFileTempVO +"删除的数据条数为"+ num);
		return num;
	}

	@Override
	public int insert(GzBankRepayPlanFileTempVO gzBankRepayPlanFileTempVO) {
		GzBankRepayPlanFileTemp gzBankRepayPlanFileTemp=new GzBankRepayPlanFileTemp();
		logger.debug("当前新增数据为:"+ gzBankRepayPlanFileTempVO.toString());
		int num = 0;
		try {		
			beanCopy(gzBankRepayPlanFileTempVO, gzBankRepayPlanFileTemp);
			
			num = gzBankRepayPlanFileTempDao.insert(gzBankRepayPlanFileTemp);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	@Override
	public int insertSelective(GzBankRepayPlanFileTempVO record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<GzBankRepayPlanFileTempVO> getRefNbrList() {
		logger.debug("当前查询数据信息的参数信息为:");
		List<GzBankRepayPlanFileTempVO> list = null;
		try {			
			List<GzBankRepayPlanFileTemp> gzBankRepayPlanFiles = gzBankRepayPlanFileTempDao.getRefNbrList();
			logger.debug("当前查询数据信息的结果集数量为:" + gzBankRepayPlanFiles.size());			
			list = (List<GzBankRepayPlanFileTempVO>) beansCopy(gzBankRepayPlanFiles, GzBankRepayPlanFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	@Override
	public List<GzBankRepayPlanFileTempVO> getBankRepayPlanList() {
		logger.debug("当前查询数据信息的参数信息为:");
		List<GzBankRepayPlanFileTempVO> list = null;
		try {			
			List<GzBankRepayPlanFileTemp> gzBankRepayPlanFiles = gzBankRepayPlanFileTempDao.getBankRepayPlanList();
			logger.debug("当前查询数据信息的结果集数量为:" + gzBankRepayPlanFiles.size());			
			list = (List<GzBankRepayPlanFileTempVO>) beansCopy(gzBankRepayPlanFiles, GzBankRepayPlanFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	@Override
	public List<GzBankRepayPlanFileTempVO> getListByRefNbr(GzBankRepayPlanFileTempVO gzBankRepayPlanFileTempVO) {
		logger.debug("当前查询数据信息的参数信息为:");
		List<GzBankRepayPlanFileTempVO> list = null;
		try {
			GzBankRepayPlanFileTemp gzBankRepayPlanFileTemp = new GzBankRepayPlanFileTemp();
			beanCopy(gzBankRepayPlanFileTempVO, gzBankRepayPlanFileTemp);
			List<GzBankRepayPlanFileTemp> gzBankRepayPlanFiles = gzBankRepayPlanFileTempDao.getListByRefNbr(gzBankRepayPlanFileTemp);
			logger.debug("当前查询数据信息的结果集数量为:" + gzBankRepayPlanFiles.size());			
			list = (List<GzBankRepayPlanFileTempVO>) beansCopy(gzBankRepayPlanFiles, GzBankRepayPlanFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	@Override
	public List<GzBankRepayPlanFileTempVO> getGzBankRepayPlanFileTempList() {
		logger.debug("当前查询数据信息的参数信息为:");
		List<GzBankRepayPlanFileTempVO> list = null;
		try {			
			List<GzBankRepayPlanFileTemp> gzBankRepayPlanFiles = gzBankRepayPlanFileTempDao.getGzBankRepayPlanFileTempList();
			logger.debug("当前查询数据信息的结果集数量为:" + gzBankRepayPlanFiles.size());			
			list = (List<GzBankRepayPlanFileTempVO>) beansCopy(gzBankRepayPlanFiles, GzBankRepayPlanFileTempVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	/**
	 *需求编号：【2019D1204】（马上账务文件同步分页处理）
	 *问题编号：【2019D1204】（马上账务文件同步分页处理）
	 *开发人员：【ludayong】
	 *创建日期：【2019/11/27 11:31】
	 *功能描述：分页查询马上还款计划临时表信息
	 *修改日期：【2019/11/27 11:31】
	 *修改描述：
	 */
	@Override
	public List<GzBankRepayPlanFileTempVO> queryByPage(GzBankRepayPlanFileTempVO gzBankRepayPlanFileTempVO) {
		String msg1 = "分页查询还款计划临时表";
		logger.debug(msg1, "message {}");
		List<GzBankRepayPlanFileTempVO> list = null;
		try {
			List<GzBankRepayPlanFileTemp> gzBankRepayPlanFiles = gzBankRepayPlanFileTempDao.queryByPage(gzBankRepayPlanFileTempVO);
			list = (List<GzBankRepayPlanFileTempVO>) beansCopy(gzBankRepayPlanFiles, GzBankRepayPlanFileTempVO.class);
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		if(list != null) {
			String msg2 = "查询的数据为大小为 " + list.size();
			logger.debug(msg2, "message {}");
		}
		return list;
	}

	/**
	 *需求编号：【2019D1204】（马上账务文件同步分页处理）
	 *问题编号：【2019D1204】（马上账务文件同步分页处理）
	 *开发人员：【ludayong】
	 *创建日期：【2019/11/27 11:31】
	 *功能描述：统计马上还款计划临时表数据量
	 *修改日期：【2019/11/27 11:31】
	 *修改描述：
	 */
	@Override
	public int queryCount() {
		String msg1 = "查询【还款计划临时表】表中数据量大小";
		logger.debug(msg1, "message {}");
		int num = 0;
		try {
			num = gzBankRepayPlanFileTempDao.queryCount();
		} catch (Exception e) {
			String msg2 = "查询【还款计划临时表】表中数据量大小出错" + e;
			logger.debug(msg2, "message {}");
			num = -1;
		}
		return num;
	}

}
